

package com.example.administrator.caigou51.recyclerCard.cardView;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.administrator.caigou51.widget.RippleView;
import com.example.administrator.caigou51.EventBusClass.GotoFragment;
import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.activity.AboutUsActivity;
import com.example.administrator.caigou51.activity.AddAgainGoodsActivity;
import com.example.administrator.caigou51.activity.CollectActivity;
import com.example.administrator.caigou51.activity.GBaseActivity;
import com.example.administrator.caigou51.activity.MainActivity;
import com.example.administrator.caigou51.activity.MessageActivity;
import com.example.administrator.caigou51.activity.MyFootActivity;
import com.example.administrator.caigou51.activity.OrderListActivity;
import com.example.administrator.caigou51.activity.StoreManagerActivity;
import com.example.administrator.caigou51.activity.UserInfoActivity;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.recyclerCard.basic.CardItemView;
import com.example.administrator.caigou51.recyclerCard.card.UserCenterCard;
import com.example.administrator.caigou51.util.ImageUtil;

import de.greenrobot.event.EventBus;


public class UserCenterCardView extends CardItemView<UserCenterCard> implements View.OnClickListener {
 	private Context mContext;
    private RippleView rippleViewQhjl;
    private RippleView rippleViewWdxx;
    private RippleView rippleViewGywm;
    private RelativeLayout relativeLayout_top_bg,relativeLayoutShopCar;
    private ImageView imageView_top_bg;
    private ImageView imageViewHead;
    private TextView textViewName,textViewShopCarCount;
    private ImageView imageViewMore;
    private TextView textViewDFK;
    private TextView textViewDSH;
    private TextView textViewYWC;
    private TextView textViewQBDD,textViewTel;
    private ImageView imageViewGwc;
    private View linearLayoutDpgl;
    private LinearLayout linearLayoutQhjl;
    private LinearLayout linearLayoutWdxx;
    private LinearLayout linearLayoutGywm;

    private RelativeLayout relativeLayoutGWC;
    private RelativeLayout relativeLayoutWDSC;
    private RelativeLayout relativeLayoutWDZJ;

    private RelativeLayout relativeLayoutDFK;
    private RelativeLayout relativeLayoutDFH;
    private RelativeLayout relativeLayoutYWC;
    private RelativeLayout relativeLayoutQBDD;

    public UserCenterCardView(Context context) {
        super(context);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public UserCenterCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public UserCenterCardView(Context context,
                              AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    @Override
    public void build(UserCenterCard card) {
        // TODO Auto-generated method stub
        super.build(card);

        rippleViewQhjl= (RippleView) findViewById(R.id.rippleViewQhjl);
        rippleViewQhjl.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
            @Override
            public void onComplete(RippleView rippleView) {
                Intent intent2 =new Intent(mContext, AddAgainGoodsActivity.class);
                mContext.startActivity(intent2);
            }
        });
        rippleViewWdxx= (RippleView) findViewById(R.id.rippleViewWdxx);
        rippleViewWdxx.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
            @Override
            public void onComplete(RippleView rippleView) {
                Intent intent5 =new Intent(mContext, MessageActivity.class);
                mContext.startActivity(intent5);
            }
        });
        rippleViewGywm= (RippleView) findViewById(R.id.rippleViewGywm);
        rippleViewGywm.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
            @Override
            public void onComplete(RippleView rippleView) {
                Intent intent99 =new Intent(mContext, AboutUsActivity.class);
                mContext.startActivity(intent99);
            }
        });
        rippleViewQhjl.setRippleColor(R.color.color_36cd66);
        rippleViewQhjl.setRippleDuration(180);
        rippleViewQhjl.setAlpha(100.0f);
        rippleViewWdxx.setRippleColor(R.color.color_36cd66);
        rippleViewWdxx.setRippleDuration(180);
        rippleViewWdxx.setAlpha(100.0f);
        rippleViewGywm.setRippleColor(R.color.color_36cd66);
        rippleViewGywm.setRippleDuration(180);
        rippleViewGywm.setAlpha(100.0f);
        relativeLayoutShopCar=(RelativeLayout) findViewById(R.id.relativeLayoutShopCar);
        relativeLayoutDFK=(RelativeLayout) findViewById(R.id.relativeLayoutDFK);relativeLayoutDFK.setOnClickListener(this);
        relativeLayoutDFH=(RelativeLayout) findViewById(R.id.relativeLayoutDFH);relativeLayoutDFH.setOnClickListener(this);
        relativeLayoutYWC=(RelativeLayout) findViewById(R.id.relativeLayoutYWC);relativeLayoutYWC.setOnClickListener(this);
        relativeLayoutQBDD=(RelativeLayout) findViewById(R.id.relativeLayoutQBDD);relativeLayoutQBDD.setOnClickListener(this);

        relativeLayout_top_bg = (RelativeLayout) findViewById(R.id.relativeLayout_top_bg);
        imageView_top_bg = (ImageView) findViewById(R.id.imageView_top_bg);imageView_top_bg.setOnClickListener(this);
        imageViewHead = (ImageView) findViewById(R.id.imageViewHead);imageViewHead.setOnClickListener(this);
        textViewName = (TextView) findViewById(R.id.textViewName);
        imageViewMore = (ImageView) findViewById(R.id.imageViewMore);
        textViewDFK = (TextView) findViewById(R.id.textViewDFK);
        textViewDSH = (TextView) findViewById(R.id.textViewDSH);
        textViewYWC = (TextView) findViewById(R.id.textViewYWC);
        textViewQBDD = (TextView) findViewById(R.id.textViewQBDD);
        textViewTel= (TextView) findViewById(R.id.textViewTel);
        textViewShopCarCount= (TextView) findViewById(R.id.textViewShopCarCount);

        imageViewGwc = (ImageView) findViewById(R.id.imageViewGwc);
        linearLayoutDpgl =  findViewById(R.id.linearLayoutDpgl);linearLayoutDpgl.setOnClickListener(this);

        /*linearLayoutQhjl = (LinearLayout) findViewById(R.id.linearLayoutQhjl);linearLayoutQhjl.setOnClickListener(this);
       linearLayoutWdxx = (LinearLayout) findViewById(R.id.linearLayoutWdxx);linearLayoutWdxx.setOnClickListener(this);
       linearLayoutGywm = (LinearLayout) findViewById(R.id.linearLayoutGywm);linearLayoutGywm.setOnClickListener(this);*/

        relativeLayoutGWC = (RelativeLayout) findViewById(R.id.relativeLayoutGWC);relativeLayoutGWC.setOnClickListener(this);
        relativeLayoutWDSC = (RelativeLayout) findViewById(R.id.relativeLayoutWDSC);relativeLayoutWDSC.setOnClickListener(this);
        relativeLayoutWDZJ = (RelativeLayout) findViewById(R.id.relativeLayoutWDZJ);relativeLayoutWDZJ.setOnClickListener(this);

        if (App.getUserBean()!=null) {
            App.displayImageHttpOrFile(App.getUserBean().getAvatar(), imageViewHead, ImageUtil.OptionsNormalRadius360_Head());
            textViewName.setText(App.getUserBean().getMobile());
        }
        if (card.getUserCenterOtherBean()!=null)
        {
            textViewDFK.setText(card.getUserCenterOtherBean().getUnpaid());
            textViewDSH.setText(card.getUserCenterOtherBean().getDelivery());
            textViewQBDD.setText(card.getUserCenterOtherBean().getTotals());
            textViewYWC.setText(card.getUserCenterOtherBean().getCompletion());
            textViewTel.setText("客服电话："+card.getUserCenterOtherBean().getCustomer_service());
        }
        //设置购物车红色数量
        GBaseActivity.RefreshShopCarRedCount(textViewShopCarCount,relativeLayoutShopCar);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId())
        {



            case R.id.imageView_top_bg:
                Intent intent22 =new Intent(mContext, UserInfoActivity.class);
                mContext.startActivity(intent22);
                break;
            case R.id.linearLayoutDpgl:
                Intent intent =new Intent(mContext, StoreManagerActivity.class);
                intent.putExtra(StoreManagerActivity.TagFromUserCenter,StoreManagerActivity.TagFromUserCenter);
                StoreManagerActivity.isFromUserCenter=true;
                mContext.startActivity(intent);
                break;

            case R.id.relativeLayoutGWC:
                Intent intent4 = new Intent(mContext,MainActivity.class);
                mContext.startActivity(intent4);
                EventBus.getDefault().post(new GotoFragment(MainActivity.TAB_GouWuChe));
                if (!((GBaseActivity)mContext).getLocalClassName().contains("MainActivity"))
                    ((GBaseActivity)mContext).finish();
                break;
            case R.id.relativeLayoutWDSC:
                Intent intent6 = new Intent(mContext,CollectActivity.class);
                mContext.startActivity(intent6);
                break;
            case R.id.relativeLayoutWDZJ:
                Intent intent9=new Intent(mContext, MyFootActivity.class);
                mContext.startActivity(intent9);
                break;
            case R.id.relativeLayoutDFK:
                Intent intent3=new Intent(mContext, OrderListActivity.class);
                intent3.putExtra(OrderListActivity.TagOrderType,OrderListActivity.DFK+"");
                mContext.startActivity(intent3);
                break;
            case R.id.relativeLayoutDFH:
                Intent intent3_1=new Intent(mContext, OrderListActivity.class);
                intent3_1.putExtra(OrderListActivity.TagOrderType,OrderListActivity.DSH+"");
                mContext.startActivity(intent3_1);
                break;
            case R.id.relativeLayoutYWC:
                Intent intent3_2=new Intent(mContext, OrderListActivity.class);
                intent3_2.putExtra(OrderListActivity.TagOrderType,OrderListActivity.JYWG+"");
                mContext.startActivity(intent3_2);
                break;
            case R.id.relativeLayoutQBDD:
                Intent intent3_3=new Intent(mContext, OrderListActivity.class);
                intent3_3.putExtra(OrderListActivity.TagOrderType,OrderListActivity.ALL+"");
                mContext.startActivity(intent3_3);
                break;
        }
    }
}
